<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AlterJtkCouponOrderData extends Migrator
{

    public function up()
    {
        if (isProd()) {
            $couponOrder = \app\model\CouponOrder::query()
                ->where('serv_type', PRODUCT_AROUND_SHOP_SERV)
                ->where('type', \app\model\CouponOrder::TYPE_COUPON_SELF_EMPLOYED)
                ->where('created_at', '<=', '2023-05-12 13:00:00')
                ->select();
            echo '需要修复的周边游订单' . count($couponOrder);
            if ($couponOrder) {
                foreach ($couponOrder as $obj) {
                    echo '需要修复的周边游订单时间' . $obj->created_at . PHP_EOL;
                    echo '需要修复的周边游订单Id' . $obj->id . PHP_EOL;
                    $obj->type = 0;
                    $obj->save();
                }
            }
        }

    }
}
